﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PHMEE.DTOS.StatusMonitor
{
    public class WaveDataFeature
    {
        /// <summary>
        /// 时间戳
        /// </summary>
        public DateTime TimeStamp { get; set; }
        /// <summary>
        /// 加速度有效值
        /// </summary>
        public float? AccRms { get; set; }
        /// <summary>
        /// 加速度有效值预警值
        /// </summary>
        public float? AccRmsWarning { get; set; }
        /// <summary>
        /// 加速度有效值报警值
        /// </summary>
        public float? AccRmsAlarm { get; set; }

        /// <summary>
        /// 加速度平均峰值
        /// </summary>
        public float? AccAvgPeak { get; set; }
        /// <summary>
        /// 加速度平均峰值预警值
        /// </summary>
        public float? AccAvgPeakWarning { get; set; }
        /// <summary>
        /// 加速度平均峰值报警值
        /// </summary>
        public float? AccAvgPeakAlarm { get; set; }

        /// <summary>
        /// 速度有效值
        /// </summary>
        public float? VelRms { get; set; }

        /// <summary>
        /// 加速度有效值预警值
        /// </summary>
        public float? VelRmsWarning { get; set; }
        /// <summary>
        /// 加速度有效值报警值
        /// </summary>
        public float? VelRmsAlarm { get; set; }

        /// <summary>
        /// 包络平均峰值
        /// </summary>
        public float? AccEnvAvgPeak { get; set; }

        /// <summary>
        /// 报警等级
        /// </summary>
        public int? AlarmLevel { get; set; }


        /// <summary>
        /// 通道号
        /// </summary>
        public int ChNo { get; set; }
        /// <summary>
        /// 通道id
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 测点id
        /// </summary>
        public Guid PointId { get; set; }
        /// <summary>
        /// 类型，0正常、 1报警
        /// </summary>
        [Required]
        public ChartEnum Type { get; set; }

        public ChartTrendModel TransformAccValid()
        {
            return new ChartTrendModel
            {
                FeatureValid = AccRms,
                FeatureValidWarning = AccRmsWarning,
                FeatureValidAlarm = AccRmsAlarm,
                Type = Type,
                ChId = Id,
                ChNo = ChNo,
                PointId = PointId,
            };
        }

        public ChartTrendModel TransformAccAccAvgPeak()
        {
            return new ChartTrendModel
            {
                FeatureValid = AccAvgPeak,
                FeatureValidWarning = AccAvgPeakWarning,
                FeatureValidAlarm = AccAvgPeakAlarm,
                Type = Type,
                ChId = Id,
                ChNo = ChNo,
                PointId = PointId,
            };
        }

        public ChartTrendModel TransformVelRms()
        {
            return new ChartTrendModel
            {
                FeatureValid = VelRms,
                FeatureValidWarning = VelRmsWarning,
                FeatureValidAlarm = VelRmsAlarm,
                Type = Type,
                ChId = Id,
                ChNo = ChNo,
                PointId = PointId,
            };
        }

        public ChartTrendModel TransformAccEnvAvgPeak()
        {
            return new ChartTrendModel
            {
                FeatureValid = AccEnvAvgPeak,
                FeatureValidWarning = null,
                FeatureValidAlarm = null,
                Type = Type,
                ChId = Id,
                ChNo = ChNo,
                PointId = PointId,
            };
        }

    }

    public class ChartTrendModel
    {
        /// <summary>
        /// 有效值
        /// </summary>
        public float? FeatureValid { get; set; }

        /// <summary>
        /// 有效值预警值
        /// </summary>
        public float? FeatureValidWarning { get; set; }

        /// <summary>
        /// 有效值报警值
        /// </summary>
        public float? FeatureValidAlarm { get; set; }

        /// <summary>
        /// 类型，0正常、 1报警
        /// </summary>
        public ChartEnum Type { get; set; }
        /// <summary>
        /// 通道id
        /// </summary>
        public Guid ChId { get; set; }
        /// <summary>
        /// 通道号
        /// </summary>
        public int ChNo { get; set; }
        /// <summary>
        /// 测点id
        /// </summary>
        public Guid PointId { get; set; }
    }
}
